<!DOCTYPE html>
{% load static %}
{% load notification_tags %}
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{% block title %}{{SITE_NAME }}{% endblock %}</title>
    <!-- 引入Bootstrap CSS -->
    <link href="{% static 'bootstrap/bootstrap.min.css' %}" rel="stylesheet">
    <!-- Bootstrap 图标 -->
    <!-- 引入bootstrap-icons -->
    <link rel="stylesheet" href="{% static 'bootstrap-icons-1.13.1/bootstrap-icons.css' %}">
    <link href="{% static 'bootstrap-icons-1.13.1/fonts/bootstrap-icons.woff' %}" rel="stylesheet">
    <link href="{% static 'bootstrap-icons-1.13.1/fonts/bootstrap-icons.woff2' %}" rel="stylesheet">
    <!-- 引入jQuery -->
    <script src="{% static 'bootstrap/jquery-3.6.0.min.js' %}"></script>
    <script src="{% static 'bootstrap/bootstrap.bundle.min.js' %}"></script>
   
    <script>
        MathJax = {
        tex: {
            inlineMath: [['$', '$'], ['\\(', '\\)']],
            displayMath: [['\\[', '\\]']],
            processEscapes: true,
            processEnvironments: true,
            packages: {'[+]': ['ams']}
        },
        startup: {
            pageReady: function() {
                return MathJax.startup.defaultPageReady().then(function() {
                    console.log('MathJax初始化成功');
                });
            }
        },
        options: {
            skipHtmlTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code'],
            ignoreHtmlClass: 'tex2jax_ignore'
        }
    };
    </script>
        <!-- CKEditor和MathJax支持 -->
    <script src="https://cdn.ckeditor.com/4.16.2/standard/ckeditor.js"></script>
  
    <script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/3.2.0/es5/tex-mml-chtml.js"></script>
    <script>
      CKEDITOR.config.mathJaxLib = '{% static 'mathjax/tex-mml-chtml.js' %}';
      CKEDITOR.on('instanceReady', function(ev) {
        ev.editor.dataProcessor.writer.setRules('p', {
          indent: false,
          breakBeforeOpen: true,
          breakAfterOpen: false,
          breakBeforeClose: false,
          breakAfterClose: true
        });
      });
    </script>
</head>
<body>
    <!-- 导航栏 -->
  

    <nav class="navbar navbar-expand-lg navbar-light bg-light">
        <div class="container">
            <a class="navbar-brand" href="#">{{ SITE_NAME }}</a>

            <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
                <span class="navbar-toggler-icon"></span>
            </button>
            <div class="collapse navbar-collapse" id="navbarNav">
                <ul class="navbar-nav me-auto">
                    <li class="nav-item">
                        <a class="nav-link active" aria-current="page" href="{% url 'index' %}"><i class="bi bi-house me-2"></i>首页</a>
                    </li>
                 
{% if user.is_authenticated %}
    {% if request.session.CURRENT_ROLE == 'principal' %}
                    <span hidden="hidden">校长菜单开始</span>
                    <li class="nav-item">
                        <a class="nav-link" href="{% url 'core:principal_dashboard' %}"><i class="bi bi-speedometer2 me-2"></i>学校仪表盘</a>
                    </li>
                
                    <li class="nav-item">
                        <a class="nav-link" href="{% url 'core:schedule_manager_index' %}"><i class="bi bi-calendar-week me-2"></i>课程表管理</a>
                    </li>
                    <li class="nav-item dropdown">
                        <a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
                            <i class="bi bi-people me-2"></i>学生管理
                        </a>
                        <ul class="dropdown-menu">
                            <li><a class="dropdown-item" href="{% url 'core:log_list' %}"><i class="bi bi-file-text me-2"></i>日志管理</a></li>
                            <li><a class="dropdown-item" href="{% url 'core:honor_record_list' %}"><i class="bi bi-award me-2"></i>表彰记录</a></li>
                            <li><a class="dropdown-item" href="{% url 'core:honor_type_list' %}"><i class="bi bi-trophy me-2"></i>荣誉类型</a></li>
                            <li><a class="dropdown-item" href="{% url 'core:discipline_record_list' %}"><i class="bi bi-exclamation-triangle me-2"></i>违纪记录</a></li>
                            <li><a class="dropdown-item" href="{% url 'core:discipline_type_list' %}"><i class="bi bi-exclamation-circle me-2"></i>违纪类型</a></li>
                        </ul>
                    </li>
                    <li class="nav-item">
                            <a class="nav-link" href="{% url 'admin:index' %}"><i class="bi bi-gear me-2"></i>后台管理</a>
                    </li>
    <span hidden="hidden">校长菜单结束</span>
    {% elif request.session.CURRENT_ROLE == 'grade_leader' %}
    <span hidden="hidden">年级组长菜单开始</span>
                    <li class="nav-item">
                        <a class="nav-link" href="{% url 'core:grade_leader_dashboard' grade_id=CURRENT_GRADE_ID %}"><i class="bi bi-bar-chart me-2"></i>年级管理仪表盘</a>
                    </li>
                    <li>
                        <a class="nav-link" href="{% url 'core:schedule_manager_index'  %}"><i class="bi bi-calendar-week me-2"></i>日程表管理</a>
                    </li>
                   

                    <li class="nav-item dropdown">
                        <a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
                            <i class="bi bi-bar-chart me-2"></i>年级管理
                        </a>
                        <ul class="dropdown-menu">
                            <li><a class="dropdown-item" href="{% url 'core:grade_schedule_list' %}"><i class="bi bi-people me-2"></i>年级课程安排</a></li>
                            <li><a class="dropdown-item" href="{% url 'core:honor_record_list' %}"><i class="bi bi-award me-2"></i>表彰记录</a></li>
                            <li><a class="dropdown-item" href="{% url 'core:discipline_record_list' %}"><i class="bi bi-exclamation-triangle me-2"></i>违纪记录</a></li>
                            <li><a class="dropdown-item" href="{% url 'core:discipline_type_list' %}"><i class="bi bi-exclamation-circle me-2"></i>违纪类型</a></li>
                            <li><a class="dropdown-item" href="{% url 'core:course_period_list' %}"><i class="bi bi-people me-2"></i>设置课程时长</a></li>
                        </ul>
                    </li>
    <span hidden="hidden">年级组长菜单结束</span>
    {% elif request.session.CURRENT_ROLE == 'homeroom_teacher' %}
    <span hidden="hidden">班主任菜单开始</span>
                    <li class="nav-item">
                        <a class="nav-link" href="{% url 'core:home_teacher_dashboard' request.session.CLASS_ID %}"><i class="bi bi-building me-2"></i>班级仪表盘</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="{% url 'core:attendance_records' %}"><i class="bi bi-clipboard-check me-2"></i>考勤记录</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="{% url 'core:homework_list' %}"><i class="bi bi-book me-2"></i>布置作业</a>
                    </li>
                    <li class="nav-item dropdown">
                        <a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
                            <i class="bi bi-building me-2"></i>班级管理
                        </a>
                        <ul class="dropdown-menu">
                            <li><a class="dropdown-item" href="{% url 'core:task_list' %}"><i class="bi bi-list-task me-2"></i>班级事务</a></li>
                            <li><a class="dropdown-item" href="{% url 'core:leave_request_list' %}"><i class="bi bi-calendar-x me-2"></i>请假管理</a></li>
                            <li><a class="dropdown-item" href="{% url 'core:student_list' %}"><i class="bi bi-people me-2"></i>学生管理</a></li>
                            <li><a class="dropdown-item" href="{% url 'core:student_comment_management' %}"><i class="bi bi-chat-left-text me-2"></i>学生评语管理</a></li> 
                            <li><a class="dropdown-item" href="{% url 'core:schedule_manager_index' %}"><i class="bi bi-calendar-week me-2"></i>课程表管理</a></li>
                        </ul>
                    </li>
    <span hidden="hidden">班主任菜单结束</span>
    {% elif request.session.CURRENT_ROLE == 'teacher' %}
    <span hidden="hidden">教师菜单开始</span>
                    <li class="nav-item">
                        <a class="nav-link" href="{% url 'core:teacher_dashboard' %}"><i class="bi bi-speedometer2 me-2"></i>仪表盘</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="{% url 'core:homework_list' %}"><i class="bi bi-book me-2"></i>布置作业</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="{% url 'core:schedule_manager_index' %}"><i class="bi bi-calendar3 me-2"></i>查看课程表</a>
                    </li>
                    <li class="nav-item dropdown">
                        <a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
                            <i class="bi bi-book me-2"></i>教学管理
                        </a>
                        <ul class="dropdown-menu">
                            <li><a class="dropdown-item" href="{% url 'core:mistake_list' %}"><i class="bi bi-pencil-square me-2"></i>添加错题</a></li>
    
                            {% if CURRENT_SUBJECT_ID %}
                            <li><a class="dropdown-item" href="{% url 'core:subject_chapter_knowledge' subject_id=CURRENT_SUBJECT_ID %}"><i class="bi bi-journal-text me-2"></i>学科章节知识点管理</a></li>
                            {% endif %}
                        </ul>
                    </li>
    <span hidden="hidden">教师菜单结束</span>


    {% elif request.session.CURRENT_ROLE == 'assistant' %}
    <span hidden="hidden">班级小助手菜单开始</span>
    <span hidden="hidden">班级小助手菜单结束</span>
    {% endif %}
{% endif %}
                   
                
                     <li class="nav-item">
                            <a class="nav-link" href="{% url 'core:notification_list' %}"><i class="bi bi-bell me-2"></i>通知
                                {% unread_notifications_count as unread_count %}
                                    {% if unread_count > 0 %}
                                        <span class="badge bg-danger rounded-pill">{{ unread_count }}</span>
                                    {% endif %}
                                
                            </a>
                        </li>
                        
                       
                </ul>
               
                <ul class="navbar-nav" >
                    {% if user.is_authenticated %}
                        <li class="nav-item">
                            <span class="nav-link">欢迎, {{ user.profile.real_name }} (<span class="user-role">{% if request.session.CURRENT_ROLE == 'principal' %}校长{% elif request.session.CURRENT_ROLE == 'grade_leader' %}年级组长{% elif request.session.CURRENT_ROLE == 'homeroom_teacher' %}班主任{% elif request.session.CURRENT_ROLE == 'teacher' %}教师{% elif request.session.CURRENT_ROLE == 'assistant' %}班级小助手{% endif %}</span>)!</span>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" href="{% url 'core:switch_role' %}"><i class="bi bi-person-badge me-2"></i>切换身份</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" href="{% url 'admin:logout' %}"><i class="bi bi-box-arrow-right me-2"></i>退出</a>
                        </li>
                    {% else %}
                        <li class="nav-item">
                            <a class="nav-link" href="{% url 'core:login' %}"><i class="bi bi-box-arrow-in-right me-2"></i>登录</a>
                        </li>
                    {% endif %}
                </ul>
            </div>
        </div>
    </nav>
  
    <div class="container mt-4">
        {% block content %}
        {% endblock %}
    </div>

    <!-- 底部栏 -->
    <style>
        .navbar-nav .nav-link {
            transition: all 0.3s ease;
        }
        .navbar-nav .nav-link:hover {
            color: #fff;
            background-color: #0d6efd;
            transform: translateY(-2px);
        }
        .user-role {
            color: green;
        }
        .navbar-nav .nav-link:active {
            transform: translateY(0);
        }
        body {
            display: flex;
            flex-direction: column;
            min-height: 100vh;
        }
        .container {
            flex: 1;
        }
        footer {
            margin-top: auto;
            border-radius: 10px;
        }
    </style>
    <footer class="navbar-light bg-light text-center py-3 mt-4">
        <div class="container">
            <p>&copy; 2025 学生管理系统. 保留所有权利.</p>
        </div>
    </footer>
    {% block extra_js %}{% endblock %}
</body>
</html>